{extend name="layout:base" /}

{block name="content"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        {volist name="project" id="vo"}
        <div class="layui-col-xs6 layui-col-sm4 layui-col-md3">
            <div class="layui-card" >
                <div class="layui-card-body layui-text">
                    <table class="layui-table">
                        <colgroup><col width="100"><col></colgroup>
                        <tbody>
                        <tr>
                            <td><a class="layui-btn layui-btn-primary layui-btn-fluid show" data-id="{$vo.id}">{$vo.title}</a></td>
                        </tr>
                        <tr><td>底价：{$vo.price_base}元</td></tr>
                        <tr><td>建议价：{$vo.price}元</td></tr>
                        <tr>
                            <td align="center">
                                <a class="layui-btn layui-btn-sm sign" company_id="{$Think.session.user.id}" data-id="{$vo.id}" data-type="独立">独立签单</a>
                                <a class="layui-btn layui-btn-sm sign" company_id="{$Think.session.user.id}" data-id="{$vo.id}" data-type="协助">协助签单</a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        {/volist}
    </div>

</div>
{/block}

{block name="script"}
<script>
    layui.config({
        base: '__STATIC__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    // }).use(['index', 'console'],function () {
    }).use(['index', 'console', 'table', 'util','form'], function () {
        var $ = layui.$,form = layui.form,layer = layui.layer,table = layui.table;

        $('.sign').on('click',function () {
            var company_id=$(this).attr('company_id');
            var project_id=$(this).attr('data-id');
            var type=$(this).attr('data-type');

            //独立下单--询问是否下单---是---记录订单并打开客服qq
            if(type=='独立'){
                layer.msg('是否独立下单？', {
                    time: 0 //不自动关闭
                    ,btn: ['是', '否']
                    ,yes: function(index){
                        layer.close(index);
                        window.open('http://wpa.qq.com/msgrd?v=3&uin={$company.kfqq}&&menu=yes');
                        $.post("{:url('add_task')}", {company_id:company_id,project_id:project_id,type:type}, function (res) {
                            if (res['code'] == 0) {
                                layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                                    parent.location.reload();
                                });
                            } else {
                                layer.msg(res['msg'], {icon: 3, time: 3000});
                            }
                        });
                    }
                });
            }

            //协助下单-弹出表单-下单
            if (type=='协助'){
                var url = "{:url('task_add_Form')}?company_id=" + company_id+"&project_id=" + project_id;
                console.log(url);
                var index = layer.open({
                    type: 2,
                    title: '协助签单填表',
                    area: ['90%', '90%'],
                    shade: 0,
                    maxmin: true,
                    content: url,
                    zIndex: layer.zIndex
                });


            }




            // $.post("{:url('show_project')}", {id:id}, function (res) {
            //     if (res['code'] == 0) {
            //         var data=res['data'];
            //         console.log(data);
            //
            //     } else {
            //         layer.msg(result['msg'], {icon: 3, time: 3000});
            //     }
            // });

        });



        $('.show').on('click',function () {
            var id=$(this).attr('data-id');
            $.post("{:url('show_project')}", {id:id}, function (res) {
                if (res['code'] == 0) {
                    var data=res['data'];
                    console.log(data);
                    layer.open({
                        type: 1 //Page层类型
                        ,area: ['500px', '300px']
                        ,title: data['title']+' 介绍'
                        ,shade: 0.6 //遮罩透明度
                        ,maxmin: true //允许全屏最小化
                        ,anim: 1 //0-6的动画形式，-1不开启
                        ,content: '<div style="padding:50px;">'+data['content']+'</div>'
                    });
                } else {
                    layer.msg(result['msg'], {icon: 3, time: 3000});
                }
            });

        });
    });
</script>
{/block}





